package com.lyf.scm.plan.domain.repository;

import com.lyf.scm.plan.api.dto.SalesPlanPermissionsDTO;
import com.lyf.scm.plan.domain.convertor.SalesPlanPermissionsConvertor;
import com.lyf.scm.plan.insfrastructure.db.mapper.SalesPlanPermissionsMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 权限respository
 *
 * @author Martin
 * @date 2020-10-31 11:13
 */
@Service
public class SalesPlanPermissionsRespository {

    @Resource
    private SalesPlanPermissionsMapper salesPlanPermissionsMapper;
    @Resource
    private SalesPlanPermissionsConvertor salesPlanPermissionsConvertor;

    public List<SalesPlanPermissionsDTO> listByUserId(Long userId) {
        return salesPlanPermissionsConvertor.doToDTO(salesPlanPermissionsMapper.listByUserId(userId));
    }

    public int batchSave(List<SalesPlanPermissionsDTO> list) {
        return salesPlanPermissionsMapper.batchSave(salesPlanPermissionsConvertor.dtoToDO(list));
    }

    public int updateById(SalesPlanPermissionsDTO salesPlanPermissionsDTO) {
        return salesPlanPermissionsMapper.updateById(salesPlanPermissionsConvertor.dtoToDO(salesPlanPermissionsDTO));
    }
}
